<?php
##############################################
#
#   分类管理
# @ Time : 2017-1-3 - 下午10:45:24
# @ Author : JiangYongWei <1085562810@qq.com>
# @ Encoding : UTF-8 language : PHP
#
##############################################

namespace Admin\Controller;
use Admin\Model\ShopModel;
use Admin\Model\AdminBaseModel;


class ShopController extends AdminBaseController {
	
	protected $_shop;
	
	public function _initialize(){
		parent::_initialize();
		$this -> _shop  = new ShopModel();
	}
	
	/**
	 * 商铺列表
	 */
	public function shopList(){
		if(IS_GET){
			$data = $this -> _shop -> getShop();
			$this -> assign('shop', $data);
			$this -> display('shop_list');
		}
	}
	
	/**
	 * 添加商铺
	 */
	public function addShop(){
		$data = I('post.');
		$admin_base_model = new AdminBaseModel('shop');
		$result = $admin_base_model -> addData($data);
		if($result)
			$this -> success('添加成功', U('shopList'), 1);
		else
			$this -> error('操作失败', '', 1);
	}
	
	/**
	 * 删除商铺
	 */
	public function deleteShop(){
		if(!IS_AJAX) return;
		$result = $this -> _shop -> deleteShop(intval($_GET['shopid']));
		if($result)
			$this -> ajaxReturn(array('status' => 1,'message' => '删除成功'));
		else
			$this -> ajaxReturn(array('status' => 2,'message' => '操作失败'));
	}
	
}



	
	